
PWM Taper algorithm  for

Gizmo's Charger with gilMod for taper PWM above an Amp threshold.




The calculation is derrived from two basic calculations:


Max duty cycle / max possible Range of watts for tapering  = Duty coefficient

and

Watts subject to amp tapering x Duty coefficient = Duty cycle


where;
Max duty cycle = Max duty of 4kHz @ 4MHz = 1000  (See pwmout wizard in Programming Editor)
Max possible Range of watts = size of Volt range tapering is to be applied to x Amp range tapering is to be applied to

further;
Volt range = Voltage upper set point - Voltage lower set point
Amp range = Max amps possible - Amp threshold
Watts subject to amp tapering = (Volt reading - Voltage lower set point) x Amp reading - Amp threshold


combined written as:

1000 / (Voltage upper set point - Voltage lower set point) / (Amp max possible - Amp threshold) x (Volt reading - Voltage lower set point) x (Amp reading - Amp threshold) = Duty cycle

or:

(Volt reading - Voltage lower set point) * (Amp reading - Amp threshold) * 1000 / (Voltage upper set point - Voltage lower set point) / (Amp max possible - Amp threshold) = Duty


or when;
Voltage upper set point = Vu	
Voltage lower set point = Vl
Amp max possible = Am
Volt actual  = V
Amp actual  = A
Amp threshold = At

then:
(V - Vl) * (A - At) * 1000 / (Vu - VL) / (Am - At) = Duty


This calculation is done in stages to prevent word variable over/under flow.

END